#pragma once

#include <pingcap/Exception.h>
#include <pingcap/kv/Scanner.h>
#include <pingcap/kv/Snapshot.h>
#include <pingcap/kv/Txn.h>
#include <pingcap/kv/Cluster.h>
#include "Common.h"
#include "Command.h"
#include "UnboundedBuffer.h"

namespace pingcap
{
namespace kv
{

// Just for test purpose
struct TestTwoPhaseCommitter
{
private:
    TwoPhaseCommitter committer;

public:
    TestTwoPhaseCommitter(Txn *txn) : committer{txn} {}

    void prewriteKeys(Backoffer &bo, const std::vector<std::string> &keys) { committer.prewriteKeys(bo, keys); }

    void commitKeys(Backoffer &bo, const std::vector<std::string> &keys) { committer.commitKeys(bo, keys); }

    std::vector<std::string> keys() { return committer.keys; }

    void setCommitTS(int64_t commit_ts) { committer.commit_ts = commit_ts; }
};

}
}

class Executor
{

public:

    Executor();

    static void Init(const std::vector<std::string> & pd_addrs);

    static Error ExecuteCmd(const std::vector<std::string>& params, UnboundedBuffer* reply = nullptr);
   
    static pingcap::kv::ClusterPtr tikv_cluster;

};
